home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wtek0693.zip / OOPALLEY.ZIP / STACK.CPP < prev    next >
C/C++ Source or Header  |  1993-04-27  |  1KB  |  52 lines

  1. #include "stack.h"
  2.  
  3. #define THIS    Stack
  4. #define BASE    SeqCltn
  5. DEFINE_CLASS(Stack,SeqCltn);
  6.  
  7. Object* Stack::add(const Object& ob)    { return contents.add(ob); }
  8.  
  9. Collection& Stack::addContentsTo(Collection& cltn) const
  10. {
  11.     return contents.addContentsTo(cltn);
  12. }
  13.  
  14. Object*& Stack::at(int i) const       { return contents.at(size()-i-1); }
  15.  
  16. unsigned Stack::capacity() const  { return contents.capacity(); }
  17.  
  18. void Stack::deepenShallowCopy()
  19. {
  20.     BASE::deepenShallowCopy();
  21.     contents.deepenShallowCopy();
  22. }
  23.  
  24. unsigned Stack::hash() const     { return contents.hash(); }
  25.  
  26. bool Stack::isEmpty()  const     { return contents.size()==0; }
  27.  
  28. bool Stack::isEqual(const Object& ob) const
  29. {
  30.     return ob.isSpecies(class_Stack) && contents.isEqual(((Stack*)&ob)->contents);
  31. }
  32.  
  33. const Class* Stack::species() const  { return &class_Stack; }
  34.  
  35. Object* Stack::last() const      { return contents.last(); }
  36.  
  37. void Stack::printOn(ostream& strm) const
  38. {
  39.     strm << className() << "[";
  40.     for (register unsigned i=size(); i>0; i--) {
  41.         if(i<size()) strm << "\n";
  42.         contents.at(i-1)->printOn(strm);
  43.     }
  44.     strm << "]\n";
  45. }
  46.  
  47. void Stack::reSize(unsigned newSize) { contents.reSize(newSize); }
  48.  
  49. Object* Stack::removeLast() { return contents.removeLast(); }
  50.  
  51. unsigned Stack::size() const     { return contents.size(); }
  52.